<?php


namespace Tbf\Component\Io;


class EncodingConvertStringWriter implements StringWriterInterface{
    protected $writer;
    protected $from_encoding;
    protected $to_encoding;
    function __construct(StringWriterInterface $writer,$from_encoding,$to_encoding){
        $this->writer = $writer;
        $this->from_encoding = $from_encoding;
        $this->to_encoding = $to_encoding;
    }

    /**
     * @param  string $string
     * @return string 错误
     */
    public function write($string)
    {
        $this->writer->write(
            mb_convert_encoding($string,$this->to_encoding,$this->from_encoding)
        );
        return null;
    }

}